package com.yupi.yuoj.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.yupi.yuoj.model.dto.questionsubmit.QuestionSubmitAddRequest;
import com.yupi.yuoj.model.entity.ContestSubmit;
import com.yupi.yuoj.model.entity.Question;
import com.yupi.yuoj.model.entity.QuestionSubmit;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 竞赛提交服务
 */
public interface ContestSubmitService extends IService<ContestSubmit> {
    
    /**
     * 竞赛中提交题目
     *
     * @param contestId
     * @param questionSubmitAddRequest
     * @param request
     * @return
     */
    long doContestSubmit(Long contestId, QuestionSubmitAddRequest questionSubmitAddRequest, HttpServletRequest request);

    /**
     * 处理竞赛提交结果
     *
     * @param questionSubmit
     * @param question
     * @return
     */
    ContestSubmit processContestSubmitResult(QuestionSubmit questionSubmit, Question question);

    /**
     * 获取用户在竞赛中某题的提交次数
     *
     * @param contestId
     * @param questionId
     * @param userId
     * @return
     */
    int getUserQuestionAttempts(Long contestId, Long questionId, Long userId);

    /**
     * 获取用户在竞赛中已解决的题目数
     *
     * @param contestId
     * @param userId
     * @return
     */
    int getUserSolvedCount(Long contestId, Long userId);

    /**
     * 获取用户在竞赛中的所有提交
     *
     * @param contestId
     * @param userId
     * @return
     */
    List<ContestSubmit> getUserContestSubmits(Long contestId, Long userId);

    /**
     * 计算用户在竞赛中的总罚时
     *
     * @param contestId
     * @param userId
     * @return
     */
    int calculateUserTotalPenalty(Long contestId, Long userId);
}
